<?php

/**
 * @author xuananh.ho
 * @copyright 2012
 */

    include "../dbConfig.php";
    
    function connect(){
        // Ket noi den CSDL
        
        global $host;
        global $databaseName;
        global $userDB;
        global $passDB;
        
        $connection = mysql_connect($host, $userDB, $passDB);
        
        if(!$connection){
            echo "Ket noi den $host bi loi";
        }
        
        $db = mysql_select_db($databaseName);
        
        if(!$db){
            echo "Ket noi den CSDL $databaseName bi loi";
        }
        
        mysql_query("set names utf8");
    }
    
    function disconnect(){
        // Ngat ket noi den CSDL
        
        $connection = null;
    }
    
    function executeQuery($sql){
        // Thuc hien cau lenh SELECT
        
        connect();
        
        $rs = mysql_query($sql);
        
        disconnect();
        return $rs;
    }

?>